{
 "cells": [
  {
   "cell_type": "code",
   "execution_count": 3,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "[32.0, 50.0, 68.0, 86.0]\n"
     ]
    }
   ],
   "source": [
    "celsius = [0, 10, 20, 30]\n",
    "fahrenheit = list(map(lambda c: (c * 9 / 5) + 32, celsius))\n",
    "print(fahrenheit)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 4,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "['PYTHON', 'MAP', 'FUNCTION']\n"
     ]
    }
   ],
   "source": [
    "strings = [\"python\", \"map\", \"function\"]\n",
    "uppercased = list(map(str.upper, strings))\n",
    "print(uppercased)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 5,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "<class 'map'>\n",
      "[1, 2, 3]\n"
     ]
    }
   ],
   "source": [
    "result = map(int, [\"1\", \"2\", \"3\"])  # At this point, nothing is computed.\n",
    "print(type(result))  # Now the computation is done and the result is printed.\n",
    "print(list(result))  # The result is a list of integers: [1, 2, 3]"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 5,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "[5, 7]\n"
     ]
    }
   ],
   "source": [
    "list1 = [1, 2, 3]\n",
    "list2 = [4, 5]\n",
    "result = list(map(lambda x, y: x + y, list1, list2))\n",
    "\n",
    "print(result)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 8,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "[1, 4, 9]"
      ]
     },
     "execution_count": 8,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "# Less readable:\n",
    "list(map(lambda x: x**2, [1, 2, 3]))\n",
    "# More readable:\n",
    "[x**2 for x in [1, 2, 3]]"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 6,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "[8, 9, 4]\n"
     ]
    }
   ],
   "source": [
    "# Two lists representing numbers and their exponents\n",
    "bases = [2, 3, 4]\n",
    "exponents = [3, 2, 1]\n",
    "\n",
    "\n",
    "# Function that takes two arguments and raises the base to the power of the exponent\n",
    "def power(base: float, exp: float) -> float:\n",
    "    return base**exp\n",
    "\n",
    "\n",
    "# Applying the function to both lists in parallel\n",
    "result = map(power, bases, exponents)\n",
    "\n",
    "# Convert the result to a list and print\n",
    "print(list(result))"
   ]
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": ".venv",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.13.0"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 2
}
